package com.cssy.xxkj.basic.dao.impl;

import java.util.List;

import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.cssy.xxkj.basic.dao.BasicProductBomDAO;
import com.cssy.xxkj.basic.entity.BasicProductBomDO;
import com.plat.helper.SearchConditions;

/**
 * 数据访问对象实现类
 * @since 2014-09-19
 */
public class BasicProductBomDAOImpl extends SqlMapClientDaoSupport implements BasicProductBomDAO {

    /**
     * 插入数据
     * @param basicProductBomDO
     * @return 插入数据的主键
     */
    public String insertBasicProductBomDO(BasicProductBomDO basicProductBomDO) {
        Object id = getSqlMapClientTemplate().insert("BasicProductBom.insert", basicProductBomDO);
        return (String) id;
    }

    /**
     * 统计记录数
     * @param basicProductBomDO
     * @return 查出的记录数
     */
    public Integer countBasicProductBomDOByExample(BasicProductBomDO basicProductBomDO) {
        Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicProductBom.countByDOExample", basicProductBomDO);
        return count;
    }

    /**
     * 更新记录
     * @param basicProductBomDO
     * @return 受影响的行数
     */
    public Integer updateBasicProductBomDO(BasicProductBomDO basicProductBomDO) {
        int result = getSqlMapClientTemplate().update("BasicProductBom.update", basicProductBomDO);
        return result;
    }

    /**
     * 获取对象列表
     * @param basicProductBomDO
     * @return 对象列表
     */
    @SuppressWarnings("unchecked")
    public List<BasicProductBomDO> findListByExample(BasicProductBomDO basicProductBomDO) {
        List<BasicProductBomDO> list = getSqlMapClientTemplate().queryForList("BasicProductBom.findListByDO", basicProductBomDO);
        return list;
    }

    /**
     * 根据主键获取basicProductBomDO
     * @param id
     * @return basicProductBomDO
     */
    public BasicProductBomDO findBasicProductBomDOByPrimaryKey(String id) {
        BasicProductBomDO basicProductBomDO = (BasicProductBomDO) getSqlMapClientTemplate().queryForObject("BasicProductBom.findByPrimaryKey", id);
        return basicProductBomDO;
    }

    /**
     * 删除记录
     * @param id
     * @return 受影响的行数
     */
    public Integer deleteBasicProductBomDOByPrimaryKey(String id) {
        Integer rows = (Integer) getSqlMapClientTemplate().delete("BasicProductBom.deleteByPrimaryKey", id);
        return rows;
    }

	@Override
	public List<BasicProductBomDO> find(SearchConditions scs)
			throws DataAccessException {
		List<BasicProductBomDO> list = getSqlMapClientTemplate().queryForList("BasicProductBom_ex.find", scs);
        return list;
	}

	@Override
	public Integer count(SearchConditions scs) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicProductBom_ex.count", scs);
        return count;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws DataAccessException {
		Integer count = (Integer) getSqlMapClientTemplate().queryForObject("BasicProductBom_ex.deleteBizRemoved", id);
        return count;
	}

}